import request from "../request.js"
import cfg from "../config.js"
import tabs from "../tabs.js"
import utils from "../utils.js"
import page_ext from "../page/crud_page_ext.js"


let page_type = {
  open: function (page_info) {

      let page_html_id=page_info.page_html_id;
      let property=page_info.property.scope;
      let resource=property.resource;
      let process=property.process;
      let station=property.station;

      let amisJSON=
      {
        "type":"page",
        "body":
      [{
          "type": "form",
          "title":"",
          "mode": "horizontal",
          "actions":[],
          "api": {
            "method": "post",
            "url": cfg.api_server +"mes/mesprocess/sn",
            "requestAdaptor": function (api) {
            },
            "adaptor": function (data, response) {

              alert(data.data.result);
              return {"result":"abc+"+data.data.result};
            }
          },
          "body": [
            {
              "type": "group",
              "className":"text-xl bg-gray-50	",
              "body":[
                {
                  "name": "resource",
                  "type": "static",
                  "label": "产线:",
                  "value": resource,
                  "className":"font-bold	",
                  "size": "full"   
                },
                {
                  "name": "process",
                  "type": "static",
                  "label": "工序:",
                  "value": process,
                  "className":"font-bold	",
                  "size": "full" 
                },
                {
                  "name": "station",
                  "type": "static",
                  "label": "工位:",
                  "className":"font-bold	",
                  "value": station,
                  "size": "full"  
                }
              ]
            },
            {
              "type": "divider"
            },
            {
              "name": "tip",
              "type": "static",
              "label": "",
              "size":"full",
              "className":"text-xl bg-gray-200 text-green-500	font-bold",
              "value":"请扫描条码！"
            },
            {
              "name": "text",
              "type": "input-text",
              "label": "条码:",
              "size":"full",
              "className":"text-xl text-gray-900 font-bold",
              "inline": false,
              "required":true
            },
              {
                "name": "result",
                "type": "static",
                "label": "",
                "className":"text-xl bg-gray-200 text-red-500	font-bold",
                "value":""
              }
          ]
        },
        {
          "type": "tabs",
          "className":"text-xl",
          "tabs": [
            {
              "title": "操作记录",
              "tab": "Content 1"
            }
          ]
        }]
      };
      let amis = amisRequire('amis/embed');

      let amisScoped = amis.embed(
        '#' + page_html_id, amisJSON, {},
        {
          theme: 'antd'
        }
      );
    }
  }
  
  export default page_type;